home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 February: Tool Chest / Apple Developer CD Series Tool Chest February 1996 (Apple Computer)(1996).iso / Sample Code / AppsToGo / DTS.Draw / IdleTasks.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-09-22  |  2.3 KB  |  82 lines  |  [TEXT/MPS ]

  1. /*
  2. ** Apple Macintosh Developer Technical Support
  3. **
  4. ** File:        IdleTasks.c
  5. ** Written by:    Eric Soldan
  6. **
  7. ** Copyright © 1990-1993 Apple Computer, Inc.
  8. ** All rights reserved.
  9. */
  10.  
  11. /* You may incorporate this sample code into your applications without
  12. ** restriction, though the sample code has been provided "AS IS" and the
  13. ** responsibility for its operation is 100% yours.  However, what you are
  14. ** not permitted to do is to redistribute the source as "DSC Sample Code"
  15. ** after having made changes. If you're going to re-distribute the source,
  16. ** we require that you make it clear in the source that the code was
  17. ** descended from Apple Sample Code, but that you've made changes. */
  18.  
  19. /* This function is called when a null event is received.  Do appropriate tasks
  20. ** for null event situations, such as handling balloon help for window. */
  21.  
  22.  
  23.  
  24. /*****************************************************************************/
  25.  
  26.  
  27.  
  28. #include "App.h"            /* Get the application includes/typedefs, etc.    */
  29. #include "App.protos.h"        /* Get the prototypes for application.            */
  30.  
  31.  
  32.  
  33. /*****************************************************************************/
  34. /*****************************************************************************/
  35.  
  36. #ifdef applec
  37. #pragma segment DTSDrawSeg1
  38. #endif
  39.  
  40. /*****************************************************************************/
  41. /*****************************************************************************/
  42.  
  43.  
  44.  
  45. void    DoIdleTasks(EventRecord *event)
  46. {
  47. #ifndef __MWERKS__
  48. #pragma unused (event)
  49. #endif
  50.  
  51.     EventRecord        evt;
  52.     WindowPtr        window;
  53.     TEHandle        te;
  54.     Rect            rr;
  55.     KeyMap            kk;
  56.     short            mm;
  57.  
  58.     if (TSMTEAvailable()) TSMEvent(event);
  59.  
  60.     GetKeys(kk);
  61.     mm  = (kk[1] & 0x8000) ? (cmdKey    ) : 0;
  62.     mm |= (kk[1] & 0x0004) ? (optionKey ) : 0;
  63.     mm |= (kk[1] & 0x0008) ? (controlKey) : 0;
  64.     mm |= (kk[1] & 0x0001) ? (shiftKey  ) : 0;
  65.     evt.what      = nullEvent;        /* Make valid null event, with modifiers. */
  66.     evt.modifiers = mm;
  67.     IsCtlEvent(nil, &evt, nil, nil);
  68.  
  69.     window = CTETargetInfo(&te, &rr);
  70.     if (window) {
  71.         if (rr.left < -8192)        /* If TextEdit control is in the frame...  */
  72.             BeginFrame(window);        /* Set clipping to the frame area.           */
  73.         else
  74.             BeginContent(window);    /* Else set clipping to the document area. */
  75.         CTEIdle();
  76.         EndContent(window);            /* EndContent can be used to close a BeginFrame. */
  77.     }
  78. }
  79.  
  80.  
  81.  
  82.